package gui;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.RenderingHints;
import java.awt.geom.Area;

/**
 * @author Ramy Refky 
 * */
public class BufferComponentLabel extends ComponentLabel{

	private static final long serialVersionUID = 1L;
	
	/**
	 * Constructor initializes ComponentLabel.
	 * @param XLocation, YLocation, Width, Height
	 */
	public BufferComponentLabel(int xLoc,int yLoc,int originalWidth, int originalHeight){
		super(xLoc,yLoc,originalWidth,originalHeight);
	}
	/**
	 * Paints the BUFFER gate graphics.
	 */
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
	
		Point p1 = new Point(newWidth/6+3,3);
		Point p2 = new Point(newWidth/6+3,newHeight-3);
		Point p3 = new Point((int) (newWidth*0.85),newHeight/2);

		int[] xs = { p1.x, p2.x, p3.x };
		int[] ys = { p1.y, p2.y, p3.y };
		Polygon triangle = new Polygon(xs, ys,3);
		
		Area shape = new Area(triangle);
		
    	Graphics2D g2 = (Graphics2D)g;
    	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
    	
        g2.setStroke(new BasicStroke(4f));
        g2.setPaint(Color.black);
        g2.draw(shape);
        
        if(!selected)
        	g2.setPaint(Color.white);
        else
        	g2.setPaint(Color.getHSBColor((float)0.5,(float)0.1,(float)0.9));

        g2.fill(shape); 
        g2.setStroke(new BasicStroke(2f));
        
	}
	
}
